package com.example.base.demo.condition;

import com.example.base.demo.configuration.TestService;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.boot.system.JavaVersion;
import org.springframework.context.annotation.Bean;
import javax.naming.*;
/**
 * @author TangDan
 * @version 1.0
 * @since 2023/3/14
 */
@AutoConfiguration
public class TestConditionConfig {


/*    @Bean
    @ConditionalOnJava(value = JavaVersion.SEVENTEEN, range = ConditionalOnJava.Range.OLDER_THAN)
    public TestService testServiceBean() {
        return new TestService();
    }*/

/*    @Bean
    @ConditionalOnResource(resources = {"application.properties"})
    public TestService testServiceBean() {
        return new TestService();
    }*/

/*    @Bean
    @ConditionalOnSingleCandidate(value=TestCondition.class)
    public TestService testServiceBean() {
        return new TestService();
    }*/


/*    @Bean
    // `@ConditionalOnWarDeployment`表示采用`War `包打包部署时才会加载当前`Bean`：
    @ConditionalOnWarDeployment


    臻品系列
      - Spring Boot 3.0
      - Spring Security 6.0
      - Nacos 2.0

    public TestService testServiceBean() {
        return new TestService();
    }*/

    @Bean
    // `@ConditionalOnExpression`表示当前`SpEL`表达式计算结果为`true`时，才会加载当前`Bean`：
    @ConditionalOnExpression("1==1")
    public TestService testServiceBean() {
        return new TestService();
    }


}
